<?php

namespace App\Jobs;

use App\Services\WxCardService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

/**
 * 卡券同步任务
 * @package App\Jobs
 */
class WxCardSyncOneCard implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 120;

    protected $cardType;
    protected $cardInfo;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($cardType, $cardInfo = [])
    {
        $this->cardType = $cardType;
        $this->cardInfo = $cardInfo;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(WxCardService $wxCardService)
    {
        $wxCardService->createCardObj($this->cardType)->sync($this->cardInfo);
    }
}
